/*
 * @lc app=leetcode.cn id=1089 lang=javascript
 *
 * [1089] 复写零
 */

// @lc code=start
/**
 * @param {number[]} arr
 * @return {void} Do not return anything, modify arr in-place instead.
 */
var duplicateZeros = function(arr) {
    let len=arr.length
    for(let i=0;i<len;i++){
        if(arr[i]==0){
           for(let j=len-1;j>i;j--){
               arr[j]=arr[j-1]
           }
           i++
        }
       
    }
};
// @lc code=end

let a=[1,0,2,3,4]
duplicateZeros(a)
var duplicateZeros = function(arr) {
    var s = arr.length
    while (s>=0) {
    if(arr[s] === 0){
      
      arr.splice(s,0,0)
      arr.pop()
    }
    s--
   }
};//splice api在原数组上修改